package pers.cj.pdos.controller.dialog;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import pers.cj.pdos.utils.Utils;

@Controller
@RequestMapping("/select")
public class SelectController {
    @RequestMapping("/selectGoodsForCheckHouse")
    public String selectGoodsForCheckHouse(Model model,String houseId){
        if (!Utils.isEmpty(houseId)){
            model.addAttribute("houseId", houseId);
        }

        return "/dialog/select/selectGoodsForCheckHouse";
    }

    /**
     * 商品选择
     * @param model
     * @param sn 是否开启sn
     * @param numberBar 1：+-、序列号区分显示,点击sn后，进入sn录入界面； 2:+-、序列号区分显示，点击sn按钮后进入sn选择框; 其他：只显示+-
     * @param checkStock 是否检查库存 1是 2否
     * @param priceFlag 显示价格 1.参考进货价 2最低售价 3批发价 4零售价
     * @return
     */
    @RequestMapping("/selectGoods")
    public String selectGoods(Model model, String sn, String numberBar, String houseId, String checkStock, String priceFlag){
        model.addAttribute("sn", Utils.genBoolean(sn));
        model.addAttribute("numberBar", Utils.genInteger(numberBar));
        model.addAttribute("checkStock", Utils.genInteger(checkStock));
        if (!Utils.isEmpty(houseId)){
            model.addAttribute("houseId", houseId);
        }

        if (!Utils.isEmpty(priceFlag)){
            model.addAttribute("priceFlag", Utils.genInteger(priceFlag));
        }
        return "/dialog/select/selectGoods";
    }

    /**
     *
     * @param model
     * @param houseId -仓库id
     * @param checkStock 是否检查库存
     * @return
     */
    @RequestMapping("/selectPacket")
    public String selectPacket(Model model, String houseId, String checkStock){
        if (!Utils.isEmpty(houseId)){
            model.addAttribute("houseId", houseId);
        }
        model.addAttribute("checkStock", Utils.genInteger(checkStock));
        return "/dialog/select/selectPacket";
    }

    /**
     *
     * @param model
     * @param houseId -仓库id
     * @param checkStock 是否检查库存
     * @return
     */
    @RequestMapping("/selectGoodsTemplate")
    public String selectGoodsTemplate(Model model, String houseId, String checkStock){
        if (!Utils.isEmpty(houseId)){
            model.addAttribute("houseId", houseId);
        }
        model.addAttribute("checkStock", Utils.genInteger(checkStock));
        return "/dialog/select/selectGoodsTemplate";
    }

    @RequestMapping("/selectProvider")
    public String selectProvider(){
        return "/dialog/select/selectProvider";
    }

    @RequestMapping("/selectCustom")
    public String selectCustom(){
        return "/dialog/select/selectCustom";
    }

    @RequestMapping("/selectInGoods")
    public String selectInGoods(){
        return "/dialog/select/selectInGoods";
    }

    @RequestMapping("/selectSale")
    public String selectSale(){
        return "/dialog/select/selectSale";
    }
}
